﻿using Tszy.Unlimited.Base.Collections;
using Tszy.Unlimited.Data.AdoNet.Sql.Components;

namespace Tszy.Unlimited.Data.AdoNet.Sql
{
    /// <summary>
    /// 查询扩展。
    /// </summary>
    public static class QueryExtensions
    {
        #region In

        /// <summary>
        /// SQL Where In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool In(this int obj, params int[] parameters)
        {
            if (parameters == null)
                return false;

            if (parameters.Length == 0)
                return false;

            for (var i = 0; i < parameters.Length; i++)
            {
                if (parameters[i] == obj)
                    return true;
            }

            return false;
        }

        /// <summary>
        /// SQL Where In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值集合。</param>
        /// <returns>是否成功。</returns>
        public static bool In(this int obj, IEnumerable<int> parameters)
        {
            if (parameters == null)
                return false;

            if (!parameters.Any())
                return false;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return true;
            }

            return false;
        }

        /// <summary>
        /// SQL Where In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool In(this int? obj, params int?[] parameters)
        {
            if (parameters == null)
                return false;

            if (obj == null)
                return false;

            if (!parameters.Any())
                return false;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return true;
            }

            return false;
        }

        /// <summary>
        /// SQL Where In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool In(this int? obj, IEnumerable<int?> parameters)
        {
            if (parameters == null)
                return false;

            if (obj == null)
                return false;

            if (!parameters.Any())
                return false;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return true;
            }

            return false;
        }

        /// <summary>
        /// SQL Where In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool In(this long obj, params long[] parameters)
        {
            if (parameters == null)
                return false;

            if (!parameters.Any())
                return false;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return true;
            }

            return false;
        }

        /// <summary>
        /// SQL Where In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool In(this long obj, IEnumerable<long> parameters)
        {
            if (parameters == null)
                return false;

            if (!parameters.Any())
                return false;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return true;
            }

            return false;
        }

        /// <summary>
        /// SQL Where In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool In(this long? obj, params long?[] parameters)
        {
            if (parameters == null)
                return false;

            if (obj == null)
                return false;

            if (!parameters.Any())
                return false;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return true;
            }

            return false;
        }

        /// <summary>
        /// SQL Where In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool In(this long? obj, IEnumerable<long?> parameters)
        {
            if (parameters == null)
                return false;

            if (obj == null)
                return false;

            if (!parameters.Any())
                return false;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return true;
            }

            return false;
        }

        /// <summary>
        /// SQL Where In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool In(this short obj, params short[] parameters)
        {
            if (parameters == null)
                return false;

            if (!parameters.Any())
                return false;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return true;
            }

            return false;
        }

        /// <summary>
        /// SQL Where In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool In(this short obj, IEnumerable<short> parameters)
        {
            if (parameters == null)
                return false;

            if (!parameters.Any())
                return false;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return true;
            }

            return false;
        }

        /// <summary>
        /// SQL Where In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool In(this short? obj, params short?[] parameters)
        {
            if (parameters == null)
                return false;

            if (obj == null)
                return false;

            if (!parameters.Any())
                return false;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return true;
            }

            return false;
        }

        /// <summary>
        /// SQL Where In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool In(this short? obj, IEnumerable<short?> parameters)
        {
            if (parameters == null)
                return false;

            if (obj == null)
                return false;

            if (!parameters.Any())
                return false;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return true;
            }

            return false;
        }

        /// <summary>
        /// SQL Where In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool In(this float obj, params float[] parameters)
        {
            if (parameters == null)
                return false;

            if (!parameters.Any())
                return false;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return true;
            }

            return false;
        }

        /// <summary>
        /// SQL Where In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool In(this float obj, IEnumerable<float> parameters)
        {
            if (parameters == null)
                return false;

            if (!parameters.Any())
                return false;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return true;
            }

            return false;
        }

        /// <summary>
        /// SQL Where In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool In(this float? obj, params float?[] parameters)
        {
            if (parameters == null)
                return false;

            if (obj == null)
                return false;

            if (!parameters.Any())
                return false;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return true;
            }

            return false;
        }

        /// <summary>
        /// SQL Where In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool In(this float? obj, IEnumerable<float?> parameters)
        {
            if (parameters == null)
                return false;

            if (obj == null)
                return false;

            if (!parameters.Any())
                return false;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return true;
            }

            return false;
        }

        /// <summary>
        /// SQL Where In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool In(this double obj, params double[] parameters)
        {
            if (parameters == null)
                return false;

            if (!parameters.Any())
                return false;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return true;
            }

            return false;
        }

        /// <summary>
        /// SQL Where In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool In(this double? obj, IEnumerable<double> parameters)
        {
            if (parameters == null)
                return false;

            if (obj == null)
                return false;

            if (!parameters.Any())
                return false;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return true;
            }

            return false;
        }

        /// <summary>
        /// SQL Where In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool In(this double? obj, params double?[] parameters)
        {
            if (parameters == null)
                return false;

            if (obj == null)
                return false;

            if (!parameters.Any())
                return false;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return true;
            }

            return false;
        }

        /// <summary>
        /// SQL Where In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool In(this double? obj, IEnumerable<double?> parameters)
        {
            if (parameters == null)
                return false;

            if (obj == null)
                return false;

            if (!parameters.Any())
                return false;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return true;
            }

            return false;
        }

        /// <summary>
        /// SQL Where In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool In(this decimal obj, params decimal[] parameters)
        {
            if (parameters == null)
                return false;

            if (!parameters.Any())
                return false;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return true;
            }

            return false;
        }

        /// <summary>
        /// SQL Where In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool In(this decimal? obj, IEnumerable<decimal> parameters)
        {
            if (parameters == null)
                return false;

            if (obj == null)
                return false;

            if (!parameters.Any())
                return false;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return true;
            }

            return false;
        }

        /// <summary>
        /// SQL Where In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool In(this decimal? obj, params decimal?[] parameters)
        {
            if (parameters == null)
                return false;

            if (obj == null)
                return false;

            if (!parameters.Any())
                return false;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return true;
            }

            return false;
        }

        /// <summary>
        /// SQL Where In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool In(this decimal? obj, IEnumerable<decimal?> parameters)
        {
            if (parameters == null)
                return false;

            if (obj == null)
                return false;

            if (!parameters.Any())
                return false;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return true;
            }

            return false;
        }

        /// <summary>
        /// SQL Where In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool In(this string obj, params string[] parameters)
        {
            if (parameters == null)
                return false;

            if (obj == null)
                return false;

            if (!parameters.Any())
                return false;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return true;
            }

            return false;
        }

        /// <summary>
        /// SQL Where In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool In(this string obj, IEnumerable<string> parameters)
        {
            if (parameters == null)
                return false;

            if (obj == null)
                return false;

            if (!parameters.Any())
                return false;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return true;
            }

            return false;
        }

        /// <summary>
        /// SQL Where In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool In(this Guid obj, params Guid[] parameters)
        {
            if (parameters == null)
                return false;

            if (!parameters.Any())
                return false;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return true;
            }

            return false;
        }

        /// <summary>
        /// SQL Where In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool In(this Guid? obj, IEnumerable<Guid> parameters)
        {
            if (parameters == null)
                return false;

            if (obj == null)
                return false;

            if (!parameters.Any())
                return false;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return true;
            }

            return false;
        }

        #endregion In

        #region Not In

        /// <summary>
        /// SQL Where Not In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool NotIn(this int obj, params int[] parameters)
        {
            if (parameters == null)
                return true;

            if (!parameters.Any())
                return true;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return false;
            }

            return true;
        }

        /// <summary>
        /// SQL Where Not In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool NotIn(this int obj, IEnumerable<int> parameters)
        {
            if (parameters == null)
                return true;

            if (!parameters.Any())
                return true;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return false;
            }

            return true;
        }

        /// <summary>
        /// SQL Where Not In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool NotIn(this int? obj, params int?[] parameters)
        {
            if (parameters == null)
                return true;

            if (obj == null)
                return true;

            if (!parameters.Any())
                return true;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return false;
            }

            return true;
        }

        /// <summary>
        /// SQL Where Not In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool NotIn(this int obj, IEnumerable<int?> parameters)
        {
            if (parameters == null)
                return true;

            if (!parameters.Any())
                return true;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return false;
            }

            return true;
        }

        /// <summary>
        /// SQL Where Not In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool NotIn(this long obj, params long[] parameters)
        {
            if (parameters == null)
                return true;

            if (!parameters.Any())
                return true;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return false;
            }

            return true;
        }

        /// <summary>
        /// SQL Where Not In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool NotIn(this long obj, IEnumerable<long> parameters)
        {
            if (parameters == null)
                return true;

            if (!parameters.Any())
                return true;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return false;
            }

            return true;
        }

        /// <summary>
        /// SQL Where Not In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool NotIn(this long? obj, params long?[] parameters)
        {
            if (parameters == null)
                return true;

            if (obj == null)
                return true;

            if (!parameters.Any())
                return true;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return false;
            }

            return true;
        }

        /// <summary>
        /// SQL Where Not In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool NotIn(this long? obj, IEnumerable<long?> parameters)
        {
            if (parameters == null)
                return true;

            if (obj == null)
                return true;

            if (!parameters.Any())
                return true;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return false;
            }

            return true;
        }

        /// <summary>
        /// SQL Where Not In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool NotIn(this short obj, params short[] parameters)
        {
            if (parameters == null)
                return true;

            if (!parameters.Any())
                return true;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return false;
            }

            return true;
        }

        /// <summary>
        /// SQL Where Not In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool NotIn(this short obj, IEnumerable<short> parameters)
        {
            if (parameters == null)
                return true;

            if (!parameters.Any())
                return true;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return false;
            }

            return true;
        }

        /// <summary>
        /// SQL Where Not In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool NotIn(this short? obj, params short?[] parameters)
        {
            if (parameters == null)
                return true;

            if (obj == null)
                return true;

            if (!parameters.Any())
                return true;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return false;
            }

            return true;
        }

        /// <summary>
        /// SQL Where Not In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool NotIn(this short? obj, IEnumerable<short?> parameters)
        {
            if (parameters == null)
                return true;

            if (obj == null)
                return true;

            if (!parameters.Any())
                return true;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return false;
            }

            return true;
        }

        /// <summary>
        /// SQL Where Not In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool NotIn(this float obj, params float[] parameters)
        {
            if (parameters == null)
                return true;

            if (!parameters.Any())
                return true;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return false;
            }

            return true;
        }

        /// <summary>
        /// SQL Where Not In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool NotIn(this float obj, IEnumerable<float> parameters)
        {
            if (parameters == null)
                return true;

            if (!parameters.Any())
                return true;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return false;
            }

            return true;
        }

        /// <summary>
        /// SQL Where Not In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool NotIn(this float? obj, params float?[] parameters)
        {
            if (parameters == null)
                return true;

            if (obj == null)
                return true;

            if (!parameters.Any())
                return true;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return false;
            }

            return true;
        }

        /// <summary>
        /// SQL Where Not In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool NotIn(this float? obj, IEnumerable<float?> parameters)
        {
            if (parameters == null)
                return true;

            if (obj == null)
                return true;

            if (!parameters.Any())
                return true;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return false;
            }

            return true;
        }

        /// <summary>
        /// SQL Where Not In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool NotIn(this double obj, params double[] parameters)
        {
            if (parameters == null)
                return true;

            if (!parameters.Any())
                return true;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return false;
            }

            return true;
        }

        /// <summary>
        /// SQL Where Not In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool NotIn(this double obj, IEnumerable<double> parameters)
        {
            if (parameters == null)
                return true;

            if (!parameters.Any())
                return true;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return false;
            }

            return true;
        }

        /// <summary>
        /// SQL Where Not In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool NotIn(this double? obj, params double?[] parameters)
        {
            if (parameters == null)
                return true;

            if (obj == null)
                return true;

            if (!parameters.Any())
                return true;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return false;
            }

            return true;
        }

        /// <summary>
        /// SQL Where Not In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool NotIn(this double? obj, IEnumerable<double?> parameters)
        {
            if (parameters == null)
                return true;

            if (obj == null)
                return true;

            if (!parameters.Any())
                return true;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return false;
            }

            return true;
        }

        /// <summary>
        /// SQL Where Not In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool NotIn(this decimal obj, params decimal[] parameters)
        {
            if (parameters == null)
                return true;

            if (!parameters.Any())
                return true;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return false;
            }

            return true;
        }

        /// <summary>
        /// SQL Where Not In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool NotIn(this decimal obj, IEnumerable<decimal> parameters)
        {
            if (parameters == null)
                return true;

            if (!parameters.Any())
                return true;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return false;
            }

            return true;
        }

        /// <summary>
        /// SQL Where Not In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool NotIn(this decimal? obj, params decimal?[] parameters)
        {
            if (parameters == null)
                return true;

            if (obj == null)
                return true;

            if (!parameters.Any())
                return true;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return false;
            }

            return true;
        }

        /// <summary>
        /// SQL Where Not In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool NotIn(this decimal? obj, IEnumerable<decimal?> parameters)
        {
            if (parameters == null)
                return true;

            if (obj == null)
                return true;

            if (!parameters.Any())
                return true;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return false;
            }

            return true;
        }

        /// <summary>
        /// SQL Where Not In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool NotIn(this string obj, params string[] parameters)
        {
            if (parameters == null)
                return true;

            if (obj == null)
                return true;

            if (!parameters.Any())
                return true;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return false;
            }

            return true;
        }

        /// <summary>
        /// SQL Where Not In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool NotIn(this string obj, IEnumerable<string> parameters)
        {
            if (parameters == null)
                return true;

            if (obj == null)
                return true;

            if (!parameters.Any())
                return true;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return false;
            }

            return true;
        }

        /// <summary>
        /// SQL Where Not In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool NotIn(this Guid obj, params Guid[] parameters)
        {
            if (parameters == null)
                return true;

            if (!parameters.Any())
                return true;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return false;
            }

            return true;
        }

        /// <summary>
        /// SQL Where Not In 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="parameters">参数值数组。</param>
        /// <returns>是否成功。</returns>
        public static bool NotIn(this Guid obj, IEnumerable<Guid> parameters)
        {
            if (parameters == null)
                return true;

            if (!parameters.Any())
                return true;

            foreach (var param in parameters)
            {
                if (param == obj)
                    return false;
            }

            return true;
        }

        #endregion Not In

        #region Between

        /// <summary>
        /// SQL Where Between 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="min"></param>
        /// <param name="max"></param>
        /// <returns>是否成功。</returns>
        public static bool Between(this int obj, int min, int max)
        {
            return obj >= min && obj <= max;
        }

        /// <summary>
        /// SQL Where Between 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="min"></param>
        /// <param name="max"></param>
        /// <returns>是否成功。</returns>
        public static bool Between(this int? obj, int? min, int? max)
        {
            if (obj == null)
                return false;

            return obj >= min && obj <= max;
        }

        /// <summary>
        /// SQL Where Between 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="min"></param>
        /// <param name="max"></param>
        /// <returns>是否成功。</returns>
        public static bool Between(this long obj, long min, long max)
        {
            return obj >= min && obj <= max;
        }

        /// <summary>
        /// SQL Where Between 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="min"></param>
        /// <param name="max"></param>
        /// <returns>是否成功。</returns>
        public static bool Between(this long? obj, long? min, long? max)
        {
            if (obj == null)
                return false;

            return obj >= min && obj <= max;
        }

        /// <summary>
        /// SQL Where Between 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="min"></param>
        /// <param name="max"></param>
        /// <returns>是否成功。</returns>
        public static bool Between(this short obj, short min, short max)
        {
            return obj >= min && obj <= max;
        }

        /// <summary>
        /// SQL Where Between 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="min"></param>
        /// <param name="max"></param>
        /// <returns>是否成功。</returns>
        public static bool Between(this short? obj, short? min, short? max)
        {
            if (obj == null)
                return false;

            return obj >= min && obj <= max;
        }

        /// <summary>
        /// SQL Where Between 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="min"></param>
        /// <param name="max"></param>
        /// <returns>是否成功。</returns>
        public static bool Between(this float obj, float min, float max)
        {
            return obj >= min && obj <= max;
        }

        /// <summary>
        /// SQL Where Between 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="min"></param>
        /// <param name="max"></param>
        /// <returns>是否成功。</returns>
        public static bool Between(this float? obj, float? min, float? max)
        {
            if (obj == null)
                return false;

            return obj >= min && obj <= max;
        }

        /// <summary>
        /// SQL Where Between 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="min"></param>
        /// <param name="max"></param>
        /// <returns>是否成功。</returns>
        public static bool Between(this double obj, double min, double max)
        {
            return obj >= min && obj <= max;
        }

        /// <summary>
        /// SQL Where Between 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="min"></param>
        /// <param name="max"></param>
        /// <returns>是否成功。</returns>
        public static bool Between(this double? obj, double? min, double? max)
        {
            if (obj == null)
                return false;

            return obj >= min && obj <= max;
        }

        /// <summary>
        /// SQL Where Between 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="min"></param>
        /// <param name="max"></param>
        /// <returns>是否成功。</returns>
        public static bool Between(this decimal obj, decimal min, decimal max)
        {
            return obj >= min && obj <= max;
        }

        /// <summary>
        /// SQL Where Between 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="min"></param>
        /// <param name="max"></param>
        /// <returns>是否成功。</returns>
        public static bool Between(this decimal? obj, decimal? min, decimal? max)
        {
            if (obj == null)
                return false;

            return obj >= min && obj <= max;
        }

        /// <summary>
        /// SQL Where Between 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="min"></param>
        /// <param name="max"></param>
        /// <returns>是否成功。</returns>
        public static bool Between(this string obj, string min, string max)
        {
            return true;
        }

        /// <summary>
        /// SQL Where Between 条件。
        /// </summary>
        /// <param name="obj">参数名。</param>
        /// <param name="min"></param>
        /// <param name="max"></param>
        /// <returns>是否成功。</returns>
        public static bool Between(this DateTime obj, DateTime min, DateTime max)
        {
            return obj >= min && obj <= max;
        }

        #endregion Between

        #region get page

        /// <summary>
        /// 分页查询。
        /// </summary>
        /// <typeparam name="TSource">实体类型。</typeparam>
        /// <param name="query">查询对象。</param>
        /// <param name="pageIndex">页码。</param>
        /// <param name="pageSize">页大小。</param>
        /// <returns>查询对象。</returns>
        public static IEnumerableSelectQuery<TSource> GetPage<TSource>(this IEnumerableQuery<TSource> query, int pageIndex, int pageSize)
        {
            if (pageIndex < 1)
                pageIndex = 1;

            if (pageSize < 1)
                throw new ArgumentOutOfRangeException(nameof(pageSize));

            return query.Skip((pageIndex - 1) * pageSize).Take(pageSize);
        }

        /// <summary>
        /// 分页查询。
        /// </summary>
        /// <typeparam name="TSource">实体类型。</typeparam>
        /// <param name="query">查询对象。</param>
        /// <param name="pageIndex">页码。</param>
        /// <param name="pageSize">页大小。</param>
        /// <returns>查询对象。</returns>
        public static IEnumerableSelectQuery<TSource> GetPage<TSource>(this IThenOrderByQuery<TSource> query, int pageIndex, int pageSize)
        {
            if (pageIndex < 1)
                pageIndex = 1;

            if (pageSize < 1)
                throw new ArgumentOutOfRangeException(nameof(pageSize));

            return query.Skip((pageIndex - 1) * pageSize).Take(pageSize);
        }

        /// <summary>
        /// 分页查询。
        /// </summary>
        /// <typeparam name="TSource">实体类型。</typeparam>
        /// <param name="query">查询对象。</param>
        /// <param name="pager">分页对象。</param>
        /// <returns>查询对象。</returns>
        public static IEnumerableSelectQuery<TSource> GetPage<TSource>(this IEnumerableQuery<TSource> query, PagerParameters pager)
        {
            return query.GetPage(pager.Index, pager.Size);
        }

        /// <summary>
        /// 分页查询。
        /// </summary>
        /// <typeparam name="TSource">实体类型。</typeparam>
        /// <param name="query">查询对象。</param>
        /// <param name="pager">分页对象。</param>
        /// <returns>查询对象。</returns>
        public static IEnumerableSelectQuery<TSource> GetPage<TSource>(this IThenOrderByQuery<TSource> query, PagerParameters pager)
        {
            return query.GetPage(pager.Index, pager.Size);
        }

        #endregion get page
    }
}